<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>无标题文档</title>


<style scoped>
	/* input{border: 1px solid #ccc; padding: 5px 0px; border-radius: 3px; padding-left:5px; }
	*{color: #848482;}*/
 

</style>


<script src="/js/vue.min.js"></script>

<link href="/css/base.css" rel="stylesheet" type="text/css">

<script type="text/javascript" src="/js/axios.min.js"></script>
           
</head>

<body >
  <div id="lingyangDiv">
	       <table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#F5F5F5" style="margin-bottom:8px">
						
						<tr bgcolor="#FFFFFF" style="height: 38px;">
						    <td width="103" bgcolor="#FFFFFF" align="right">
						          姓名：
						    </td>
						    <td bgcolor="#FFFFFF" align="left">
						        <input type="text" v-model="lingyang.xingming" size="35"/>
						    </td>
						</tr>
						<tr bgcolor="#FFFFFF" style="height: 38px;">
						    <td width="103" bgcolor="#FFFFFF" align="right">
						         地址：
						    </td>
						    <td bgcolor="#FFFFFF" align="left">
						        <input type="text" v-model="lingyang.dizhi" size="55" />
						    </td>
						</tr>
						<tr bgcolor="#FFFFFF" style="height: 38px;">
						    <td width="103" bgcolor="#FFFFFF" align="right">
						         联系电话：
						    </td>
						    <td bgcolor="#FFFFFF" align="left">
						        <input type="text" v-model="lingyang.dianhua" size="35" />
						    </td>
						</tr>
						<tr bgcolor="#FFFFFF" style="height: 38px;">
						    <td width="103" bgcolor="#FFFFFF" align="right">
						        时间：
						    </td>
						    <td bgcolor="#FFFFFF" align="left">
						        <input type="text" v-model="lingyang.shijian" size="35" />
						    </td>
						</tr>
						<tr bgcolor="#FFFFFF" style="height: 38px;">
						    <td width="103" bgcolor="#FFFFFF" align="right">
						         备注：
						    </td>
						    <td bgcolor="#FFFFFF" align="left">
						        <input type="text" v-model="lingyang.beizhu" size="35" />
						    </td>
						</tr>
						<tr bgcolor="#FFFFFF" style="height: 38px;">
						    <td width="103" bgcolor="#FFFFFF" align="right">
						        &nbsp;
						    </td>
						    <td bgcolor="#FFFFFF" align="left">
						       <input type="button" value="提交" @click="lingyangAdd()" class="lanse" style="width: 86px;"/>&nbsp; 
						    </td>
						</tr>
					 </table>
  </div>
  


<script type="text/javascript">
    function getUrlParam(name) 
    {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }
	var vm = new Vue({
		
		el: '#lingyangDiv',
		data: 
		{
			lingyang:{
				id:"",
	            dongwu_id:getUrlParam('dongwu_id'),
				xingming:"",
				dizhi:"",
				
				dianhua:"",
				shijian:"",
				beizhu:"",
			},
		},
		methods: 
		{
			lingyangAdd()
			{
				if(this.lingyang.xingming =="")
				{
					alert("请输入领养者姓名");return false;
				} 
				if(this.lingyang.dianhua =="")
				{
					alert("请输入联系电话");return false;
				} 
				this.add();
			},

			add()
			{
				axios({
						method: 'POST',
						url: '/lingyangAdd',
						data: this.lingyang,
						/* params:{
							username:this.lingyang.userName,
							password:this.lingyang.userPw,
						} */
						}).then(data => {
							if (data.data.state == 66)
							{
								alert("操作成功");
								location.href="/admin/lingyang/lingyangMana.html";
							} 
						    if (data.data.state == 44)
							{
								
							}
							
						}).catch(error => {
							alert(error);
						})
			},

			/* 获取系统时间 */
			padLeftZero (str)
			{
			return ('00' + str).substr(str.length);
			},

			formateDate(date, fmt)
			{
			if (/(y+)/.test(fmt)) {
			fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
			}
			let o = {
			'M+': date.getMonth() + 1,
			'd+': date.getDate(),
			'h+': date.getHours(),
			'm+': date.getMinutes(),
			's+': date.getSeconds()
			}
			for (let k in o) {
			if (new RegExp(`(${k})`).test(fmt)) {
			let str = o[k] + '';
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : this.padLeftZero(str));
			}
			}
			return fmt;
			},
			/* 获取系统时间 */
			



		},

		created()
		{
			this.lingyang.shijian=this.formateDate(new Date(), 'yyyy-MM-dd hh:mm');
		}
	
	    
	})
</script>





</body>
</html>
